//
//  DYZSelectCarSourceTypeController.m
//  Demo
//
//  Created by 毕仲阳 on 16/8/18.
//  Copyright © 2016年 mycompany. All rights reserved.
//

#import "DYZSelectCarSourceTypeController.h"
#import "Masonry/Masonry.h"
static NSString *cellid = @"cellid";
@interface DYZSelectCarSourceTypeController ()

@property(strong,nonatomic)NSArray *datas;
@end

@implementation DYZSelectCarSourceTypeController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.tableFooterView = [[UIView alloc]init];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellid];
    self.navigationItem.title = @"选择车源类型";
    NSArray *datas = @[
                       @{@"title":@"国产"},
                       @{@"title":@"进口中规"},
                       @{@"title":@"美规"},
                       @{@"title":@"中东"},
                       @{@"title":@"欧规"},
                       @{@"title":@"加版"},
                       @{@"title":@"其它"}];
    
    self.datas = datas;
    //[self.tableView setSeparatorColor:[UIColor blackColor]];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    if (section == 0) {
        
        return 1;
    }else
    {
        return self.datas.count;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid forIndexPath:indexPath];
    if (indexPath.section == 0) {
        cell.textLabel.text = @"不限";
//        UIView *view = [[UIView alloc]init];
//        view.backgroundColor = [UIColor blackColor];
//        [cell.contentView addSubview:view];
//        CGFloat width = self.tableView.bounds.size.width - 30;
//        [view mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.height.offset(1.5);
//            make.width.offset(width);
//            make.right.offset(0);
//            make.bottom.equalTo(cell.contentView.mas_bottom);
//        }];
    }else
    {
        cell.textLabel.text = self.datas[indexPath.row][@"title"];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view;
    if (section == 0) {
        //view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, [UIScreen mainScreen].scale)];
        view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 23, 1)];
        view.backgroundColor = [UIColor blackColor];
    }else
    {
        
    }
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 0.11f;
    }else
    {
        return 20.0f;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 1) {
        UIViewController *vc = [[UIViewController alloc]init];
        vc.view.backgroundColor = [UIColor greenColor];
        [self.navigationController pushViewController:vc animated:YES];
    }
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
